package com.sabo.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Iterator;

@RestController
public class ShowHeaderController {

    @Resource
    private HttpServletRequest request;

    @GetMapping("/showHeader")
    public String showHeader(){
        HashMap<String,String> map = new HashMap<>();
        Iterator<String> iterable = request.getHeaderNames().asIterator();
        while (iterable.hasNext()){
            String headerName = iterable.next();
            map.put(headerName,request.getHeader(headerName));
        }
        return map.toString();
    }

}
